package com.zhh.controller;

import com.zhh.common.ServerResponse;
import com.zhh.dto.EncaseOrderDto;
import com.zhh.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class OrderController {


    @Autowired
    private OrderService orderService;

    /**
     * 查询订单
     */
    @RequestMapping(value = "/order/query", method = RequestMethod.GET)
    public ServerResponse queryOrder(@RequestParam(value = "suid",required = false) String suid, @RequestParam(value = "state",required = false)Integer state,int pageSize,int pageNum){
       return orderService.getOrderList(suid,state,pageSize,pageNum);
    }

    /**
     * 领取订单
     * @param orderSuid
     * @return
     */
    @RequestMapping(value = "/order/encase/mono", method = RequestMethod.POST)
    public ServerResponse monoOrder(String orderSuid){
        return orderService.encaseOrder(orderSuid);
    }

    //提交复核
    @RequestMapping(value = "/order/encase/push", method = RequestMethod.POST)
    public ServerResponse pushOrder(@RequestBody EncaseOrderDto data){
        return orderService.pushOrder(data);
    }

    //取消订单
    @RequestMapping(value = "/order/encase/abandon", method = RequestMethod.POST)
    public ServerResponse abandon(String orderSuid){
        return orderService.cancelOrder(orderSuid);
    }

    //确认订单
    @RequestMapping(value = "/order/review/confim", method = RequestMethod.POST)
    public ServerResponse confim(String orderSuid){
        return orderService.confimOrder(orderSuid);
    }


    //退回订单
    @RequestMapping(value = "/order/review/reject", method = RequestMethod.POST)
    public ServerResponse reject(String orderSuid,String msg){
        return orderService.rejectOrder(orderSuid,msg);
    }

    @RequestMapping(value = "/order/delivery/pull", method = RequestMethod.POST)
    public ServerResponse pullOrder(String orderSuid){
        return orderService.deliveryPullOrder(orderSuid);
    }

    @RequestMapping(value = "/order/delivery/delivered", method = RequestMethod.POST)
    public ServerResponse delivered(String orderSuid,String recipeicPic,String receiverAudio){
        return orderService.deliveredOrder(orderSuid,recipeicPic,receiverAudio);
    }

    @RequestMapping(value = "/order/encase/recyclefacility", method = RequestMethod.POST)
    public ServerResponse recyclefacility(String orderSuid){
        return orderService.recycleFacility(orderSuid);
    }

    @RequestMapping(value = "/order/teller/finish", method = RequestMethod.POST)
    public ServerResponse finish(String orderSuid){
        return orderService.finishOrder(orderSuid);
    }


}
